package com.jxdinfo.hussar.cloud.module.example.tjjc.towerdata.controller;

import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdata.model.TowerData;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdata.service.TowerDataService;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdata.vo.TowerDataSearchVO;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdata.vo.TowerDataVO;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;
import com.jxdinfo.hussar.support.audit.core.annotations.AuditLog;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventGrade;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventType;
import com.jxdinfo.hussar.support.mp.base.controller.HussarBaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 塔机实时数据控制器
 */
@RestController(value = "tjjc.towerdata.TowerDataController")
@AuditLog(moduleName = "塔机实时数据")
@RequestMapping(value = "/tjjc/towerData")
public class TowerDataController extends HussarBaseController<TowerData, TowerDataService> {

    private static final Logger logger = LoggerFactory.getLogger(TowerDataController.class);

    @Autowired
    private TowerDataService towerDataService;

    /**
     * 根据项目编号和塔机Id获取塔机实时监测数据
     * @param towerDataSearchVO
     * @return
     */
    @AuditLog(moduleName = "塔机实时数据", eventDesc = "查询塔机实时数据", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping(path = "findRealTimeList")
    public ApiResponse<List<TowerDataVO>> findRealTimeList(@RequestBody TowerDataSearchVO towerDataSearchVO){
        if (towerDataSearchVO == null){
            return null;
        }

        //todo 没有获取项目编号工具类

        return towerDataService.findRealTimeList(towerDataSearchVO);
    }

    /**
     * 驾驶舱-塔机今日工作情况-实时报警数量
     * @param towerDataSearchVO
     * @return
     */
    @AuditLog(moduleName = "塔机实时数据", eventDesc = "查询塔机实时数据", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @PostMapping(path = "findTowerRealTimeAlarmCount")
    public ApiResponse<Map<String, Long>> findTowerRealTimeAlarmCount(@RequestBody TowerDataSearchVO towerDataSearchVO){
        if (towerDataSearchVO == null){
            return null;
        }

        //todo 没有获取项目编号工具类

        return towerDataService.findTowerRealTimeAlarmCount(towerDataSearchVO);
    }
}
